package com.wuxi.scheduler.controller;

import com.wuxi.scheduler.pojo.seer.*;
import com.wuxi.scheduler.service.SeerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Tag(name = "仙工AGV测试")
@RequestMapping("/seer")
@RequiredArgsConstructor
@Slf4j
public class SeerController {

    private final SeerService seerService;

    @Operation(summary = "创建运单")
    @PostMapping("/setOrder")
    public SeerRobotOrderResponse setOrder(@RequestBody OrderDto orderDto) {
        return seerService.setOrder(orderDto);
    }

    @Operation(summary = "终止多个运单-通过id")
    @PostMapping("/terminate-id")
    public SeerRobotBaseResponse terminateId(@RequestParam String id) {
        return seerService.terminateOrderId(id);
    }

    @Operation(summary = "终止多个运单-通过vehicleId")
    @PostMapping("/terminate-v")
    public SeerRobotBaseResponse terminateV(@RequestParam String vehicleId) {
        return seerService.terminateOrderVechile(vehicleId);
    }


    @Operation(summary = "获取AGV信息")
    @GetMapping("/robotsStatus")
    public SeerRobotAlarmResponse robotsStatus() {
        return seerService.getRobotsStatus();
    }


    @Operation(summary = "修改运单优先级")
    @PostMapping("/setPriority")
    public SeerRobotBaseResponse setPriority(@RequestParam String id, @RequestParam int priority) {
        return seerService.setPriority(id, priority);
    }

    @Operation(summary = "运单封口")
    @PostMapping("/markComplete")
    public SeerRobotBaseResponse markComplete(@RequestParam String id) {
        return seerService.markComplete(id);
    }

    @Operation(summary = "通过运单号查询运单状态")
    @PostMapping("/orderDetails")
    public SeerOrderStatusResponse orderDetails(@RequestParam String id) {
        return seerService.orderDetails(id);
    }

    @Operation(summary = "追加运单的动作块")
    @PostMapping("/addBlocks")
    public SeerRobotBaseResponse addBlocks(@RequestBody BlockDto blockDto) {
        return seerService.addBlocks(blockDto);
    }


    @Operation(summary = "暂停AGV导航")
    @PostMapping("/gotoSitePause")
    public SeerRobotBaseResponse gotoSitePause(@RequestBody List<String> vehicles) {
        return seerService.gotoSitePause(vehicles);
    }

    @Operation(summary = "继续AGV导航任务")
    @PostMapping("/gotoSiteResume")
    public SeerRobotBaseResponse gotoSiteResume(@RequestBody List<String> vehicles) {
        return seerService.gotoSiteResume(vehicles);
    }


//    @Operation(summary ="获取机器人控制权")
//    @GetMapping("/lock")
//    public SeerRobotBaseResponse lock() {
//        List<String> vehicleIds = Arrays.asList("WRF01-TEST");
//        return seerRobotsClient.lock(vehicleIds);
//    }


}
